﻿using System.Drawing;

namespace GDI
{
    public class Ellipse : PrintableItem
    {
        private RectangleF f_Rect;
        private Pen f_Pen;
        private Brush f_FeelBrush;

        public Brush FeelBrush { get { return f_FeelBrush; } set { f_FeelBrush = value; } }

        public Pen Pen { get { return f_Pen; } set { f_Pen = value; } }

        public RectangleF Rect { get { return f_Rect; } set { f_Rect = value; } }

        public PointF Center
        {
            get { return Rect.GetCenter(); }
            set
            {
                var size = Rect.Size;
                Rect = new RectangleF(value.Substract(size.Devide(2)), size);
            }
        }

        public Ellipse(RectangleF rect, Pen pen = null, Brush FeelBrush = null)
        {
            f_FeelBrush = FeelBrush;
            f_Rect = rect;
            f_Pen = pen;
        }

        #region Overrides of PrintableItem

        /// <summary>Метод отрисовки</summary>
        /// <param name="g">Графический контент</param>
        protected override void Draw(Graphics g)
        {
            if(f_FeelBrush != null) g.FillEllipse(f_FeelBrush, f_Rect);
            if(f_Pen != null) g.DrawEllipse(f_Pen, f_Rect);
        }

        #endregion
    }
}
